
package com.huizhan.web.dao;
 
import org.springframework.data.domain.*;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import com.huizhan.web.model.*;
import java.util.*; 


@Repository 
public interface ProjectCarDao extends JpaRepository<ProjectCar,Long>
{

    /**
     * 根据项目ID获取车集合
     * @param projectId 项目ID
     * @return 车集合
     */
    List<ProjectCar> findByProjectId(Long projectId);
    
    /**
     * 分页查车集合
     * @param name 名称
     * @param phone 手机
     * @param carNo 车牌
     * @param project_Id 项目ID
     * @param pageable 分页参数
     * @return 展品集合
     */
    @Query(
        value = "SELECT * FROM project_car"
            + " WHERE (project_Id =?1) "
            + " AND (name LIKE CONCAT('%',?2,'%') OR ?2  = '')"
            + " AND (phone LIKE CONCAT('%',?3,'%') OR ?3  = '')", 
        countQuery = "SELECT COUNT(1) FROM project_car"
            + " WHERE (project_Id =?1 ) "
            + " AND (name LIKE CONCAT('%',?2,'%') OR ?2  = '')"
            + " AND (phone LIKE CONCAT('%',?3,'%') OR ?3  = '')",
        nativeQuery = true
    )
    Page<ProjectCar> findByWhere(String project_Id,String name,String phone,Pageable  pageable);
}
